package org.spp.voronoi;

import org.spp.utilities.Point;

/**
 * Line.java
 * @author Ilio Catallo, Eleonora Ciceri
 * @version 1.0
 * @see Facet
 * 
 * Description: class that implements the facet in the case of bidimensional
 *              vector spaces. In such a case the facet is a line.
 * 
 * Date: Jul 20, 2011
 */
public class Line extends Facet{
    
    /**
     * Constructor for the class Line
     * @param a
     * @param b
     * @param c
     * @param inBoundedRegion 
     */
    public Line(double a, double b, double c, boolean inBoundedRegion) {
        super(new double[]{a, b, c}, inBoundedRegion);
    }
    
    /**
     * Constructor for the class Plane
     * @param coefficients
     * @param inBoundedRegion 
     */    
    public Line(double[] coefficients, boolean inBoundedRegion){
        super(coefficients, inBoundedRegion);
    }
    
    /**
     * Constructor for the class Plane
     * @param firstCentroid
     * @param secondCentroid
     */    
    public Line(Centroid firstCentroid, Centroid secondCentroid){
        super(firstCentroid, secondCentroid);
        this.coefficients = new double[3];
        
         // Variables
        double[] mediumPoint = firstCentroid.computeMediumPoint(secondCentroid);
        double[] normal = firstCentroid.computeVectorToPoint(secondCentroid);
        
        // Store the coefficients of the line
        this.coefficients[0] = normal[0];
        this.coefficients[1] = normal[1];
        this.coefficients[2] = Point.dotProduct(normal, mediumPoint);
    }   
    
}
